// (c) Copyright slimCODE Software Inc. - www.slimcode.com
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.

using System;
using System.Collections.Generic;
using System.Text;

namespace SlimCode.SlimKeys.SlimLaunch.Utils
{
  public static class Strings
  {
    public static string Replace( string value, string oldPart, string newPart, StringComparison comparisonType )
    {
      // TODOL: Not as efficient as using a StringBuilder and a "currentPos".
      //        It's a shame .NET does not have a case insensitive Replace.
      int oldPos = 0;

      do
      {
        oldPos = value.IndexOf( oldPart, comparisonType );

        if( oldPos != -1 )
        {
          value = value.Replace( value.Substring( oldPos, oldPart.Length ), newPart );
        }
      }
      while( oldPos != -1 );

      return value;
    }
  }
}
